import request from "@/utils/request";

function page(current, size, courseName, isbn, name, publisher) {
    return request({
        method: 'GET',
        url: '/textbook/page',
        params: {
            current: current,
            size: size,
            courseName: courseName,
            isbn: isbn,
            name: name,
            publisher: publisher
        }
    });
}

function add(isbn, name, publisher, author, price, courseId, classId, publishDate) {
    return request({
        method: 'POST',
        url: '/textbook',
        data: {
            isbn: isbn,
            name: name,
            publisher: publisher,
            author: author,
            price: price,
            courseId: courseId,
            classId: classId,
            publishDate: publishDate,
        }
    });
}

function edit(id, isbn, name, publisher, author, price, courseId, classId, publishDate) {
    return request({
        method: 'PUT',
        url: '/textbook',
        data: {
            id: id,
            isbn: isbn,
            name: name,
            publisher: publisher,
            author: author,
            price: price,
            courseId: courseId,
            classId: classId,
            publishDate: publishDate,
        }
    });
}

function del(id) {
    return request({
        method: 'DELETE',
        url: `/textbook/${id}`,
    });
}

export default {
    page,
    add,
    edit,
    del
}